package com.zhongjian.technologycal.mall.activity.personal.activity;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.bigkoo.pickerview.OptionsPickerView;
import com.google.gson.Gson;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.ui.ImageGridActivity;
import com.squareup.picasso.Picasso;
import com.zhongjian.technologycal.mall.R;
import com.zhongjian.technologycal.mall.base.BaseActivity;
import com.zhongjian.technologycal.mall.base.BaseContacts;
import com.zhongjian.technologycal.mall.bean.BaseBean;
import com.zhongjian.technologycal.mall.bean.ProvinceBean;
import com.zhongjian.technologycal.mall.bean.ProxyApplyBean;
import com.zhongjian.technologycal.mall.net.ApiRetrofitClient;
import com.zhongjian.technologycal.mall.net.HttpRetrofitClient;
import com.zhongjian.technologycal.mall.utils.GetJsonDataUtil;
import com.zhongjian.technologycal.mall.utils.KeyBoardUtils;
import com.zhongjian.technologycal.mall.utils.LoadingDialog;
import com.zhongjian.technologycal.mall.utils.NetWorkUtils;
import com.zhongjian.technologycal.mall.utils.ToastUitl;
import com.zhongjian.technologycal.mall.utils.UserUtils;

import org.json.JSONArray;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import rx.Subscriber;

/**
 * Created by wei on 2017/12/25.
 * 申请代理页面实现
 */

public class ApplyPartnerActivity extends BaseActivity {
    @BindView(R.id.tv_main_title)
    TextView tv_main_title;
    @BindView(R.id.apply_tv_province)
    TextView apply_tv_province;
    @BindView(R.id.apply_et_shopping_name)
    EditText apply_et_shopping_name;
    @BindView(R.id.apply_et_shopping_phone)
    EditText apply_et_shopping_phone;
    @BindView(R.id.apply_et_shopping_address)
    EditText apply_et_shopping_address;
    @BindView(R.id.apply_iv_photo0)
    ImageView apply_iv_photo0;
    @BindView(R.id.apply_iv_photo1)
    ImageView apply_iv_photo1;
    @BindView(R.id.apply_iv_photo2)
    ImageView apply_iv_photo2;
    @BindView(R.id.apply_et_shopping_status)
    TextView apply_et_shopping_status;
    @BindView(R.id.apply_partner_tv_commit)
    TextView apply_partner_tv_commit;

    private ArrayList<ProvinceBean> options1Items1 = new ArrayList<>();
    private ArrayList<ArrayList<String>> options2Items = new ArrayList<>();
    private ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<>();
    private ArrayList<String> selectedPhotos = new ArrayList<>();

    private int pid;
    private int cid;
    private int aid;
    private String imgUrl0;
    private String imgUrl1;
    private String imgUrl2;

    private int type = 0;
    private Dialog picChooseDialog = null;
    private Dialog hintDialog = null;
    private static final int IMAGE_PICKER = 5;
    private static final int REQUEST_CODE_SELECT = 6;

    @Override
    protected void beforeInit() {
        super.beforeInit();
//        StatusBarUtil.setColorNoTranslucent(this, getResources().getColor(R.color.border_color));
//        StatusBarUtil.setMiuiStatusBarDarkMode(this, true);
        initJsonData1();
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        tv_main_title.setText("申请代理");
    }

    @Override
    public void initPresenter() {
        initViewRequestProxy();
    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_apply_partner;
    }

    @OnClick(R.id.iv_back_page)
    public void onClickBack() {
        finish();
    }

    //解析数据
    private void initJsonData1() {
        /**
         * 注意：assets 目录下的Json文件仅供参考，实际使用可自行替换文件
         * 关键逻辑在于循环体
         *
         * */

        String JsonData = new GetJsonDataUtil().getJson(this, "province_citys.json");//获取assets目录下的json文件数据

        ArrayList<ProvinceBean> jsonBean = parseData1(JsonData);//用Gson 转成实体

        /**
         * 添加省份数据
         *
         * 注意：如果是添加的JavaBean实体，则实体类需要实现 IPickerViewData 接口，
         * PickerView会通过getPickerViewText方法获取字符串显示出来。
         */
        options1Items1 = jsonBean;
        for (int i = 0; i < jsonBean.size(); i++) {//遍历省份
            ArrayList<String> CityList = new ArrayList<>();//该省的城市列表（第二级）
            ArrayList<ArrayList<String>> Province_AreaList = new ArrayList<>();//该省的所有地区列表（第三极）

            for (int c = 0; c < jsonBean.get(i).getCitys().size(); c++) {//遍历该省份的所有城市
                String CityName = jsonBean.get(i).getCitys().get(c).getCityname();
                CityList.add(CityName);//添加城市
                ArrayList<String> City_AreaList = new ArrayList<>();//该城市的所有地区列表
                //如果无地区数据，建议添加空字符串，防止数据为null 导致三个选项长度不匹配造成崩溃
                if (jsonBean.get(i).getCitys().get(c).getRegions() == null
                        || jsonBean.get(i).getCitys().get(c).getRegions().size() == 0) {
                    City_AreaList.add("");
                } else {

                    for (int d = 0; d < jsonBean.get(i).getCitys().get(c).getRegions().size(); d++) {//该城市对应地区所有数据
                        String AreaName = jsonBean.get(i).getCitys().get(c).getRegions().get(d).getRegionname();

                        City_AreaList.add(AreaName);//添加该城市所有地区数据
                    }
                }
                Province_AreaList.add(City_AreaList);//添加该省所有地区数据
            }

            /**
             * 添加城市数据
             */
            options2Items.add(CityList);

            /**
             * 添加地区数据
             */
            options3Items.add(Province_AreaList);
        }

    }


    public ArrayList<ProvinceBean> parseData1(String result) {//Gson 解析
        ArrayList<ProvinceBean> detail = new ArrayList<>();
        try {
            JSONArray jsonArray = new JSONArray(result);
            Gson gson = new Gson();
            for (int i = 0; i < jsonArray.length(); i++) {
                ProvinceBean entity = gson.fromJson(jsonArray.optJSONObject(i).toString(), ProvinceBean.class);
                detail.add(entity);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return detail;
    }

    /**
     * 选择省市区
     */
    @OnClick(R.id.apply_ll_choose_province)
    public void onClickApplyChooseProvince() {
        KeyBoardUtils.closeKeybord(apply_et_shopping_name, getBaseContext());
        KeyBoardUtils.closeKeybord(apply_et_shopping_phone, getBaseContext());
        KeyBoardUtils.closeKeybord(apply_et_shopping_address, getBaseContext());
        OptionsPickerView pvOptions = new OptionsPickerView.Builder(this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                String tx = options1Items1.get(options1).getPickerViewText() +
                        options2Items.get(options1).get(options2) +
                        options3Items.get(options1).get(options2).get(options3);
                apply_tv_province.setText(tx);
                pid = options1Items1.get(options1).getId();
                cid = options1Items1.get(options1).getCitys().get(options2).getId();
                aid = options1Items1.get(options1).getCitys().get(options2).getRegions().get(options3).getId();
            }
        })
                .setTitleText("城市选择")
                .setTitleColor(getResources().getColor(R.color.color_items_college))
                .setDividerColor(getResources().getColor(R.color.color_items_college))
                .setTextColorCenter(getResources().getColor(R.color.blue)) //设置选中项文字颜色
                .setContentTextSize(15)
                .build();

//        pvOptions.setPicker(options1Items1);//一级选择器
//        pvOptions.setPicker(options1Items, options2Items);//二级选择器
        pvOptions.setPicker(options1Items1, options2Items, options3Items);//三级选择器
        pvOptions.setSelectOptions(13, 0, 4);
        pvOptions.show();

    }

    @OnClick(R.id.apply_iv_photo0)
    public void onClickUpload0() {
        type = 0;
        picChooseDialog = new Dialog(this, R.style.pic_choose_dialog_progress);
        View view = LayoutInflater.from(getBaseContext()).inflate(
                R.layout.pic_choose_dialog, null);
        TextView choose_tv_photo1 = (TextView) view
                .findViewById(R.id.choose_tv_photo1);
        TextView choose_tv_photo2 = (TextView) view
                .findViewById(R.id.choose_tv_photo2);
        TextView choose_tv_cancel = (TextView) view
                .findViewById(R.id.choose_tv_cancel1);
        /**
         * 从相册选择图片上传
         */
        choose_tv_photo1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), ImageGridActivity.class);
                startActivityForResult(intent, IMAGE_PICKER);
                picChooseDialog.dismiss();

            }
        });
        /**
         * 相机拍照上传
         */
        choose_tv_photo2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), ImageGridActivity.class);
                intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS, true); // 是否是直接打开相机
                startActivityForResult(intent, REQUEST_CODE_SELECT);
                picChooseDialog.dismiss();
            }
        });

        // 取消
        choose_tv_cancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                picChooseDialog.dismiss();
            }
        });

        Window window = picChooseDialog.getWindow();
        window.setContentView(view);
        window.setGravity(Gravity.BOTTOM);
        window.setLayout(android.view.WindowManager.LayoutParams.MATCH_PARENT,
                android.view.WindowManager.LayoutParams.WRAP_CONTENT);
        window.setWindowAnimations(R.style.popupWindowAnimation);
        picChooseDialog.setCanceledOnTouchOutside(true);
        picChooseDialog.show();


    }

    @OnClick(R.id.apply_iv_photo1)
    public void onClickUpload1() {
        type = 1;
        picChooseDialog = new Dialog(this, R.style.pic_choose_dialog_progress);
        View view = LayoutInflater.from(getBaseContext()).inflate(
                R.layout.pic_choose_dialog, null);
        TextView choose_tv_photo1 = (TextView) view
                .findViewById(R.id.choose_tv_photo1);
        TextView choose_tv_photo2 = (TextView) view
                .findViewById(R.id.choose_tv_photo2);
        TextView choose_tv_cancel = (TextView) view
                .findViewById(R.id.choose_tv_cancel1);
        /**
         * 从相册选择图片上传
         */
        choose_tv_photo1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), ImageGridActivity.class);
                startActivityForResult(intent, IMAGE_PICKER);
                picChooseDialog.dismiss();
            }
        });
        /**
         * 相机拍照上传图片
         */
        choose_tv_photo2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), ImageGridActivity.class);
                intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS, true); // 是否是直接打开相机
                startActivityForResult(intent, REQUEST_CODE_SELECT);
                picChooseDialog.dismiss();
            }
        });

        // 取消
        choose_tv_cancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                picChooseDialog.dismiss();
            }
        });

        Window window = picChooseDialog.getWindow();
        window.setContentView(view);
        window.setGravity(Gravity.BOTTOM);
        window.setLayout(android.view.WindowManager.LayoutParams.MATCH_PARENT,
                android.view.WindowManager.LayoutParams.WRAP_CONTENT);
        window.setWindowAnimations(R.style.popupWindowAnimation);
        picChooseDialog.setCanceledOnTouchOutside(true);
        picChooseDialog.show();


    }

    @OnClick(R.id.apply_iv_photo2)
    public void onClickUpload2() {
        type = 2;
        picChooseDialog = new Dialog(this, R.style.pic_choose_dialog_progress);
        View view = LayoutInflater.from(getBaseContext()).inflate(
                R.layout.pic_choose_dialog, null);
        TextView choose_tv_photo1 = (TextView) view
                .findViewById(R.id.choose_tv_photo1);
        TextView choose_tv_photo2 = (TextView) view
                .findViewById(R.id.choose_tv_photo2);
        TextView choose_tv_cancel = (TextView) view
                .findViewById(R.id.choose_tv_cancel1);
        /**
         * 从相册选择图片上传
         */
        choose_tv_photo1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), ImageGridActivity.class);
                startActivityForResult(intent, IMAGE_PICKER);
                picChooseDialog.dismiss();
            }
        });
        /**
         * 相机拍照上传图片
         */
        choose_tv_photo2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getBaseContext(), ImageGridActivity.class);
                intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS, true); // 是否是直接打开相机
                startActivityForResult(intent, REQUEST_CODE_SELECT);
                picChooseDialog.dismiss();
            }
        });

        // 取消
        choose_tv_cancel.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                picChooseDialog.dismiss();
            }
        });

        Window window = picChooseDialog.getWindow();
        window.setContentView(view);
        window.setGravity(Gravity.BOTTOM);
        window.setLayout(android.view.WindowManager.LayoutParams.MATCH_PARENT,
                android.view.WindowManager.LayoutParams.WRAP_CONTENT);
        window.setWindowAnimations(R.style.popupWindowAnimation);
        picChooseDialog.setCanceledOnTouchOutside(true);
        picChooseDialog.show();
    }

    /**
     * 提交代理申请
     */
    @OnClick(R.id.apply_partner_tv_commit)
    public void onClickApplyProxyCommit() {
        if (!NetWorkUtils.isNetConnected(getBaseContext())) {
            ToastUitl.showShort(R.string.no_net);
            return;
        } else if (TextUtils.isEmpty(apply_et_shopping_name.getText().toString().trim())) {
            ToastUitl.showShort("商家名称不能为空～");
            return;
        } else if (TextUtils.isEmpty(apply_et_shopping_phone.getText().toString().trim())) {
            ToastUitl.showShort("手机号不能为空～");
            return;
        } else if (TextUtils.isEmpty(String.valueOf(pid))) {
            ToastUitl.showShort("所在省份不能为空～");
            return;
        } else if (TextUtils.isEmpty(apply_et_shopping_address.getText().toString().trim())) {
            ToastUitl.showShort("详细地址不能为空～");
            return;
        } else if (TextUtils.isEmpty(imgUrl0)) {
            ToastUitl.showShort("请先上传证件图片～");
            return;
        } else if (TextUtils.isEmpty(imgUrl1)) {
            ToastUitl.showShort("请先上传证件图片～");
            return;
        } else if (TextUtils.isEmpty(imgUrl2)) {
            ToastUitl.showShort("请先上传证件图片～");
            return;
        }
        Map<String, String> maps = new HashMap<String, String>();
        maps.put("address", apply_et_shopping_address.getText().toString().trim());
        maps.put("cityid", String.valueOf(cid));
        maps.put("name", apply_et_shopping_name.getText().toString().trim());
        maps.put("phone", apply_et_shopping_phone.getText().toString().trim());
        maps.put("photo1", imgUrl0);
        maps.put("photo2", imgUrl1);
        maps.put("photo3", imgUrl2);
        maps.put("provinceid", String.valueOf(pid));
        maps.put("regionid", String.valueOf(aid));

        RequestBody body = RequestBody.create(
                okhttp3.MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(maps));
        HttpRetrofitClient.getInstance(getBaseContext())
                .postUrlRequestApplyProxy(UserUtils.getUserToken(),
                        body, new Subscriber<ResponseBody>() {
                            @Override
                            public void onStart() {
                                super.onStart();
                                LoadingDialog.showDialogForLoading(ApplyPartnerActivity.this, "提交中...", true);
                            }

                            @Override
                            public void onCompleted() {
                                LoadingDialog.cancelDialogForLoading();
                            }

                            @Override
                            public void onError(Throwable e) {
                                LoadingDialog.cancelDialogForLoading();
                                ToastUitl.showShort(e.getMessage());
                            }

                            @Override
                            public void onNext(ResponseBody responseBody) {
                                LoadingDialog.cancelDialogForLoading();
                                try {
                                    Gson gson = new Gson();
                                    BaseBean baseBean = gson.fromJson(responseBody.string(), BaseBean.class);
                                    if (baseBean.getError_code() == 0) {
                                        ToastUitl.showShort("提交申请成功，请耐心等待审核～");
                                        finish();
                                    } else if (baseBean.getError_code() == 3) {
                                        Intent intent = new Intent();
                                        intent.setAction("com.broadcast.info_out_line");
                                        sendBroadcast(intent);
                                    } else {
                                        ToastUitl.showShort(baseBean.getError_message());
                                    }

                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });

    }

    /**
     * 图片上传
     *
     * @param path
     */
    private void requestUploadToImage(String path) {
        File file = new File(path);
        final RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file);
        MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
        ApiRetrofitClient.getInstance(getBaseContext()).postUrlRequestUploadPhoto(body,
                UserUtils.getUserToken(),
                new Subscriber<ResponseBody>() {
                    @Override
                    public void onStart() {
                        super.onStart();
                        LoadingDialog.showDialogForLoading(ApplyPartnerActivity.this, "上传中...", true);

                    }

                    @Override
                    public void onCompleted() {
                        LoadingDialog.cancelDialogForLoading();

                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.v("----", e.getMessage());
                        LoadingDialog.cancelDialogForLoading();
                    }

                    @Override
                    public void onNext(ResponseBody responseBody) {
                        LoadingDialog.cancelDialogForLoading();
                        try {
                            Gson gson = new Gson();
                            BaseBean baseBean = gson.fromJson(responseBody.string(), BaseBean.class);
                            if (baseBean.getError_code() == 0) {
                                ToastUitl.showShort("上传成功～");
                                if (type == 0) {
                                    Picasso.get().load(BaseContacts.BASE_URL + baseBean.getData().toString())
                                            .resize(200, 250).into(apply_iv_photo0);
                                    imgUrl0 = baseBean.getData().toString();

                                } else if (type == 1) {
                                    Picasso.get().load(BaseContacts.BASE_URL + baseBean.getData().toString())
                                            .resize(200, 250)
                                            .into(apply_iv_photo1);
                                    imgUrl1 = baseBean.getData().toString();

                                } else if (type == 2) {
                                    imgUrl2 = baseBean.getData().toString();
                                    Picasso.get().load(BaseContacts.BASE_URL + baseBean.getData().toString())
                                            .resize(200, 250).into(apply_iv_photo2);
                                }

                            } else if (baseBean.getError_code() == 3) {
                                Intent intent = new Intent();
                                intent.setAction("com.broadcast.info_out_line");
                                sendBroadcast(intent);
                            } else {
                                ToastUitl.showShort(baseBean.getError_message());
                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                    }
                });

    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data != null && requestCode == IMAGE_PICKER) {
            ArrayList<ImageItem> images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
            String imgpath = images.get(0).path;
            requestUploadToImage(imgpath);
        } else if (data != null && requestCode == REQUEST_CODE_SELECT) {
            ArrayList<ImageItem> images1 = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
            String imgpath = images1.get(0).path;
            requestUploadToImage(imgpath);
        } else {
            ToastUitl.showShort("没有图片数据～");
        }

    }

    /**
     * 初始化相关数据
     */
    private void initViewRequestProxy() {
        if (!NetWorkUtils.isNetConnected(getBaseContext())) {
            ToastUitl.showShort(R.string.no_net);
            return;
        }
        HttpRetrofitClient.getInstance(getBaseContext())
                .getUrlRequestProxyApply(UserUtils.getUserToken(),
                        new Subscriber<ResponseBody>() {
                            @Override
                            public void onStart() {
                                super.onStart();
                                LoadingDialog.showDialogForLoading(ApplyPartnerActivity.this);
                            }

                            @Override
                            public void onCompleted() {
                                LoadingDialog.cancelDialogForLoading();

                            }

                            @Override
                            public void onError(Throwable e) {
                                LoadingDialog.cancelDialogForLoading();
                                ToastUitl.showShort(e.getMessage());
                            }

                            @Override
                            public void onNext(ResponseBody responseBody) {
                                LoadingDialog.cancelDialogForLoading();
                                try {
                                    Gson gson = new Gson();
                                    ProxyApplyBean proxyApplyBean = gson.fromJson(responseBody.string(), ProxyApplyBean.class);
                                    if (proxyApplyBean.getError_code() == 0) {
                                        if (proxyApplyBean.getData().getCurStatus() == 0) {
                                            apply_et_shopping_status.setVisibility(View.VISIBLE);
                                            apply_et_shopping_status.setText("审核中...");
                                            apply_partner_tv_commit.setVisibility(View.GONE);

                                            apply_et_shopping_name.setText(proxyApplyBean.getData().getName());
                                            apply_tv_province.setText(proxyApplyBean.getData().getProvinceName() +
                                                    proxyApplyBean.getData().getCityName() + proxyApplyBean.getData().getRegionName());
                                            apply_et_shopping_phone.setText(proxyApplyBean.getData().getPhone());
                                            apply_et_shopping_address.setText(proxyApplyBean.getData().getAddress());

//                                            Glide.with(getBaseContext()).load(BaseContacts.BASE_URL
//                                                    + proxyApplyBean.getData().getPhoto1()).into(apply_iv_photo0);
//                                            Glide.with(getBaseContext()).load(BaseContacts.BASE_URL
//                                                    + proxyApplyBean.getData().getPhoto2()).into(apply_iv_photo1);
//                                            Glide.with(getBaseContext()).load(BaseContacts.BASE_URL
//                                                    + proxyApplyBean.getData().getPhoto3()).into(apply_iv_photo2);

                                            Picasso.get().load(BaseContacts.BASE_URL
                                                    + proxyApplyBean.getData().getPhoto1())
                                                    .resize(200, 250).into(apply_iv_photo0);
                                            Picasso.get().load(BaseContacts.BASE_URL
                                                    + proxyApplyBean.getData().getPhoto2())
                                                    .resize(200, 250).into(apply_iv_photo1);
                                            Picasso.get().load(BaseContacts.BASE_URL
                                                    + proxyApplyBean.getData().getPhoto3())
                                                    .resize(200, 250).into(apply_iv_photo2);

                                            apply_et_shopping_name.setFocusable(false);
                                            apply_tv_province.setClickable(false);
                                            apply_et_shopping_phone.setFocusable(false);
                                            apply_et_shopping_address.setFocusable(false);
                                            apply_iv_photo0.setClickable(false);
                                            apply_iv_photo1.setClickable(false);
                                            apply_iv_photo2.setClickable(false);

                                        } else if (proxyApplyBean.getData().getCurStatus() == 1) {
                                            apply_et_shopping_status.setVisibility(View.VISIBLE);
                                            apply_et_shopping_status.setText("代理申请审核通过");
                                            apply_partner_tv_commit.setVisibility(View.GONE);
                                            apply_et_shopping_name.setText(proxyApplyBean.getData().getName());
                                            apply_tv_province.setText(proxyApplyBean.getData().getProvinceName() +
                                                    proxyApplyBean.getData().getCityName() + proxyApplyBean.getData().getRegionName());
                                            apply_et_shopping_phone.setText(proxyApplyBean.getData().getPhone());
                                            apply_et_shopping_address.setText(proxyApplyBean.getData().getAddress());

                                            Picasso.get().load(BaseContacts.BASE_URL
                                                    + proxyApplyBean.getData().getPhoto1())
                                                    .resize(200,250)
                                                    .into(apply_iv_photo0);
                                            Picasso.get().load(BaseContacts.BASE_URL
                                                    + proxyApplyBean.getData().getPhoto2())
                                                    .resize(200,250)
                                                    .into(apply_iv_photo1);
                                            Picasso.get().load(BaseContacts.BASE_URL
                                                    + proxyApplyBean.getData().getPhoto3())
                                                    .resize(200,250)
                                                    .into(apply_iv_photo2);

                                            apply_et_shopping_name.setFocusable(false);
                                            apply_tv_province.setClickable(false);
                                            apply_et_shopping_phone.setFocusable(false);
                                            apply_et_shopping_address.setFocusable(false);
                                            apply_iv_photo0.setClickable(false);
                                            apply_iv_photo1.setClickable(false);
                                            apply_iv_photo2.setClickable(false);

                                        }

                                    } else if (proxyApplyBean.getError_code() == -1) {
                                        apply_et_shopping_status.setVisibility(View.VISIBLE);
                                        apply_et_shopping_status.setText("审核失败，请重新提交资料审核");
                                        apply_et_shopping_name.setFocusable(true);
                                        apply_tv_province.setClickable(true);
                                        apply_et_shopping_phone.setFocusable(true);
                                        apply_et_shopping_address.setFocusable(true);
                                        apply_iv_photo0.setClickable(true);
                                        apply_iv_photo1.setClickable(true);
                                        apply_iv_photo2.setClickable(true);

                                    } else if (proxyApplyBean.getError_code() == 3) {
                                        Intent intent = new Intent();
                                        intent.setAction("com.broadcast.info_out_line");
                                        sendBroadcast(intent);
                                    } else {
                                        ToastUitl.showShort(proxyApplyBean.getError_message());
                                    }

                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                            }
                        });

    }
}
